// 获取元素
const logOut = document.querySelector('.logout');
const aList = document.querySelectorAll('.nav>li>a');
const aaList = document.querySelectorAll('.nav ul a');
// console.log(aList); // 验证a标签伪数组获取成功

// 点击退出并跳转
logOut.addEventListener('click', () => {
    if (confirm('确认退出吗？')) {
        localStorage.removeItem('tokenwa');
        location.href = 'login.html';
    }
})

// forEach 遍历伪数组，一级标题绑定点击事件
aList.forEach(item => {
    item.addEventListener('click', () => {
        item.nextElementSibling.classList.toggle('show');
    })
})

// forEach 遍历伪数组，二级标题绑定点击事件
aaList.forEach(item => {
    item.addEventListener('click', () => {
        const itemActive = document.querySelector('.nav ul a.active');
        itemActive.classList.remove('active');
        item.classList.add('active');
    })
})
